[
  {
    "id": "6162cad1.5fbc54",
    "type": "sonos-universal",
    "z": "25081f9e.f5f34",
    "confignode": "88e9fa70.4a53e8",
    "command": "household.get.groups",
    "state": "",
    "stateType": "str",
    "avoidCheckPlayerAvailability": false,
    "name": "",
    "x": 241,
    "y": 1683,
    "wires": [
      [
        "a5ac24fd.39eda8"
      ]
    ]
  },
  {
    "id": "a5ac24fd.39eda8",
    "type": "split",
    "z": "25081f9e.f5f34",
    "name": "split group",
    "splt": "\\n",
    "spltType": "str",
    "arraySplt": 1,
    "arraySpltType": "len",
    "stream": false,
    "addname": "",
    "x": 439,
    "y": 1683,
    "wires": [
      [
        "52490b6b.2bd554"
      ]
    ]
  },
  {
    "id": "42da530c.e6e47c",
    "type": "sonos-universal",
    "z": "25081f9e.f5f34",
    "confignode": "88e9fa70.4a53e8",
    "command": "group.create.snap",
    "state": "",
    "stateType": "str",
    "avoidCheckPlayerAvailability": false,
    "name": "",
    "x": 709,
    "y": 1723,
    "wires": [
      [
        "f9aeefd2.81d0e"
      ]
    ]
  },
  {
    "id": "52490b6b.2bd554",
    "type": "change",
    "z": "25081f9e.f5f34",
    "name": "Set snapshot properties",
    "rules": [
      {
        "t": "set",
        "p": "playerName",
        "pt": "msg",
        "to": "payload[0].playerName",
        "tot": "msg"
      },
      {
        "t": "set",
        "p": "snapVolumes",
        "pt": "msg",
        "to": "true",
        "tot": "bool"
      },
      {
        "t": "set",
        "p": "snapMutestates",
        "pt": "msg",
        "to": "true",
        "tot": "bool"
      }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 490,
    "y": 1723,
    "wires": [
      [
        "42da530c.e6e47c"
      ]
    ]
  },
  {
    "id": "f9aeefd2.81d0e",
    "type": "join",
    "z": "25081f9e.f5f34",
    "name": "join groups snap",
    "mode": "auto",
    "build": "string",
    "property": "payload",
    "propertyType": "msg",
    "key": "topic",
    "joiner": "\\n",
    "joinerType": "str",
    "accumulate": false,
    "timeout": "",
    "count": "",
    "reduceRight": false,
    "reduceExp": "",
    "reduceInit": "",
    "reduceInitType": "",
    "reduceFixup": "",
    "x": 734,
    "y": 1683,
    "wires": [
      [
        "ded91223.8c5dd"
      ]
    ]
  },
  {
    "id": "36c2013b.149e8e",
    "type": "link in",
    "z": "25081f9e.f5f34",
    "name": "create household snapshot: start",
    "links": [],
    "x": 54,
    "y": 1683,
    "wires": [
      [
        "6162cad1.5fbc54"
      ]
    ]
  },
  {
    "id": "ded91223.8c5dd",
    "type": "change",
    "z": "25081f9e.f5f34",
    "name": "set flow variable",
    "rules": [
      {
        "t": "set",
        "p": "householdSnapshot",
        "pt": "flow",
        "to": "payload",
        "tot": "msg"
      }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 924,
    "y": 1683,
    "wires": [
      [
        "1771f4d3.060ceb",
        "33da512c.231aee"
      ]
    ]
  },
  {
    "id": "a0a66691.d95cf8",
    "type": "inject",
    "z": "25081f9e.f5f34",
    "name": "trigger",
    "props": [
      {
        "p": "payload"
      },
      {
        "p": "topic",
        "vt": "str"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payloadType": "date",
    "x": 114,
    "y": 1723,
    "wires": [
      [
        "6162cad1.5fbc54"
      ]
    ]
  },
  {
    "id": "1771f4d3.060ceb",
    "type": "link out",
    "z": "25081f9e.f5f34",
    "name": "create household snapshot: start",
    "links": [],
    "x": 1077,
    "y": 1683,
    "wires": []
  },
  {
    "id": "560a3349.18adfc",
    "type": "link in",
    "z": "25081f9e.f5f34",
    "name": "restore household snapshot: start",
    "links": [],
    "x": 54,
    "y": 1856,
    "wires": [
      [
        "51a2efc6.772c4"
      ]
    ]
  },
  {
    "id": "51a2efc6.772c4",
    "type": "change",
    "z": "25081f9e.f5f34",
    "name": "restore from flow variable",
    "rules": [
      {
        "t": "set",
        "p": "payload",
        "pt": "msg",
        "to": "householdSnapshot",
        "tot": "flow"
      }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 251,
    "y": 1856,
    "wires": [
      [
        "2a726a5c.8af7b6"
      ]
    ]
  },
  {
    "id": "2a726a5c.8af7b6",
    "type": "split",
    "z": "25081f9e.f5f34",
    "name": "split snap",
    "splt": "\\n",
    "spltType": "str",
    "arraySplt": 1,
    "arraySpltType": "len",
    "stream": false,
    "addname": "",
    "x": 449,
    "y": 1856,
    "wires": [
      [
        "33b43891.954d98"
      ]
    ]
  },
  {
    "id": "33b43891.954d98",
    "type": "change",
    "z": "25081f9e.f5f34",
    "name": "set playerName",
    "rules": [
      {
        "t": "set",
        "p": "playerName",
        "pt": "msg",
        "to": "payload.membersData[0].playerName",
        "tot": "msg"
      }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 492,
    "y": 1894,
    "wires": [
      [
        "e86b25e3.728c58"
      ]
    ]
  },
  {
    "id": "e86b25e3.728c58",
    "type": "sonos-universal",
    "z": "25081f9e.f5f34",
    "confignode": "88e9fa70.4a53e8",
    "command": "group.play.snap",
    "state": "",
    "stateType": "str",
    "avoidCheckPlayerAvailability": false,
    "name": "",
    "x": 683,
    "y": 1894,
    "wires": [
      [
        "511a5c97.a2da54"
      ]
    ]
  },
  {
    "id": "851786be.0cd4a8",
    "type": "inject",
    "z": "25081f9e.f5f34",
    "name": "trigger",
    "props": [
      {
        "p": "payload"
      },
      {
        "p": "topic",
        "vt": "str"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payloadType": "date",
    "x": 114,
    "y": 1896,
    "wires": [
      [
        "51a2efc6.772c4"
      ]
    ]
  },
  {
    "id": "b4321803.d207c8",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "restore group states from flow variable \"householdSnapshot\"",
    "info": "# restore group states from flow variable\n\n## Use case\n- to play a notification on all players\n- to listen to tv, podcast, line in  and restore after\n- \nWorks together with create household snapshot flow\n\n## Customizing\n - edit `group.play.snap` and select your configuration node.\n - edit `restore from flow variable` node to define a different flow variable (optionally)\n\n## Result\nThe original state is restored in all groups.\n\n## Restrictions\nWhat is not restored\n - the original household topology is not restore\n - the queue state such as shuffle or normal\n - the queue entries",
    "x": 259,
    "y": 1823,
    "wires": [],
    "icon": "node-red/subflow.svg"
  },
  {
    "id": "414c2f8b.f00eb",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "create snapshop and save in flow variable \"householdSnapshot\"",
    "info": "# Creates a snapshot of all group states and the topology in household.\n\n## Use case\n - to play a notification on all players\n - to listen to tv, podcast, line in and restore after\n\nWorks together with flow to restore household snapshot.\n\n## Customizing\n - edit `household.get.group`, `group.create.snap` and select your configuration node.\n - edit `set flow variable` node to define a different flow variable (optionally)\n\n## Result\nAn array of group state snapshopts are stored in the the flow variable. That can be used to restore the household players state.\n\n## Limitations\nWhat is not stored: \n - the queue state such as shuffle or normal\n - the queue entries\n ",
    "x": 269,
    "y": 1651,
    "wires": [],
    "icon": "node-red/subflow.svg"
  },
  {
    "id": "1d9709f0.e93166",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "Example 09 Household snapshot and grouping",
    "info": "",
    "x": 185,
    "y": 1615,
    "wires": [],
    "icon": "node-red-contrib-sonos-plus/sonos.png"
  },
  {
    "id": "355071e3.75cf1e",
    "type": "link out",
    "z": "25081f9e.f5f34",
    "name": "restore household snapshot: end",
    "links": [],
    "x": 965,
    "y": 1856,
    "wires": []
  },
  {
    "id": "33da512c.231aee",
    "type": "debug",
    "z": "25081f9e.f5f34",
    "name": "",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "true",
    "targetType": "full",
    "statusVal": "",
    "statusType": "auto",
    "x": 1014,
    "y": 1721,
    "wires": []
  },
  {
    "id": "56622eb.11089d",
    "type": "debug",
    "z": "25081f9e.f5f34",
    "name": "",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "true",
    "targetType": "full",
    "statusVal": "",
    "statusType": "auto",
    "x": 863,
    "y": 1893,
    "wires": []
  },
  {
    "id": "2a8e796.4a28886",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "↑just for testing",
    "info": "\n ",
    "x": 119,
    "y": 1928,
    "wires": []
  },
  {
    "id": "e9a92b48.97d058",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "↑ just for testing",
    "info": "\n ",
    "x": 119,
    "y": 1756,
    "wires": []
  },
  {
    "id": "511a5c97.a2da54",
    "type": "join",
    "z": "25081f9e.f5f34",
    "name": "join groups snap",
    "mode": "auto",
    "build": "string",
    "property": "payload",
    "propertyType": "msg",
    "key": "topic",
    "joiner": "\\n",
    "joinerType": "str",
    "accumulate": false,
    "timeout": "",
    "count": "",
    "reduceRight": false,
    "reduceExp": "",
    "reduceInit": "",
    "reduceInitType": "",
    "reduceFixup": "",
    "x": 713,
    "y": 1856,
    "wires": [
      [
        "56622eb.11089d",
        "355071e3.75cf1e"
      ]
    ]
  },
  {
    "id": "721200ae.054a5",
    "type": "link in",
    "z": "25081f9e.f5f34",
    "name": "restore household topology: start",
    "links": [],
    "x": 56,
    "y": 2039,
    "wires": [
      [
        "220deafb.f86326"
      ]
    ]
  },
  {
    "id": "220deafb.f86326",
    "type": "change",
    "z": "25081f9e.f5f34",
    "name": "restore from flow variable",
    "rules": [
      {
        "t": "set",
        "p": "payload",
        "pt": "msg",
        "to": "householdSnapshot",
        "tot": "flow"
      }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 254,
    "y": 2039,
    "wires": [
      [
        "b9f2373e.3c56d8"
      ]
    ]
  },
  {
    "id": "a474fde9.320a7",
    "type": "split",
    "z": "25081f9e.f5f34",
    "name": "split snap",
    "splt": "\\n",
    "spltType": "str",
    "arraySplt": 1,
    "arraySpltType": "len",
    "stream": false,
    "addname": "",
    "x": 626,
    "y": 2039,
    "wires": [
      [
        "e620d11.285013"
      ]
    ]
  },
  {
    "id": "e620d11.285013",
    "type": "change",
    "z": "25081f9e.f5f34",
    "name": "create csv",
    "rules": [
      {
        "t": "set",
        "p": "payload",
        "pt": "msg",
        "to": "$join(payload.membersData.playerName, ',')\t",
        "tot": "jsonata"
      }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 652,
    "y": 2077,
    "wires": [
      [
        "d19c3ef7.4399c"
      ]
    ]
  },
  {
    "id": "d19c3ef7.4399c",
    "type": "sonos-universal",
    "z": "25081f9e.f5f34",
    "confignode": "88e9fa70.4a53e8",
    "command": "household.create.group",
    "state": "",
    "stateType": "str",
    "avoidCheckPlayerAvailability": false,
    "name": "",
    "x": 858,
    "y": 2077,
    "wires": [
      [
        "65355b70.f421b4"
      ]
    ]
  },
  {
    "id": "a350d2f9.b9ccd",
    "type": "inject",
    "z": "25081f9e.f5f34",
    "name": "trigger",
    "props": [
      {
        "p": "payload"
      },
      {
        "p": "topic",
        "vt": "str"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payloadType": "date",
    "x": 116,
    "y": 2079,
    "wires": [
      [
        "220deafb.f86326"
      ]
    ]
  },
  {
    "id": "af18af1.6fcdd5",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "restore topologoy from flow variable \"householdSnapshot\"",
    "info": "restore topologoy from flow variable \"householdSnapshot\"\n\n## Use case\n- to play a notification on all players and roll back\n\n## Customizing\n - edit `household.create.group`,  and select your configuration node.\n - edit `set flow variable` node to define a different flow variable (optionally)\n\n## Result\nAll household players are grouped as defined in the snapshot\n\n## Limitation\n - The coordinator can not be set in this flow. \n - It may take some seconds until SONOS player have finished their jobs.\n\n## CAUTION\nIn case your household has a lot of players the creation of a group may take too long and therefore the group creation will fail. ",
    "x": 251,
    "y": 2006,
    "wires": [],
    "icon": "node-red/subflow.svg"
  },
  {
    "id": "ba401a28.07edd8",
    "type": "link out",
    "z": "25081f9e.f5f34",
    "name": "restore household topology: end",
    "links": [],
    "x": 1144,
    "y": 2039,
    "wires": []
  },
  {
    "id": "dd9aeada.78aa08",
    "type": "debug",
    "z": "25081f9e.f5f34",
    "name": "",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "true",
    "targetType": "full",
    "statusVal": "",
    "statusType": "auto",
    "x": 1082,
    "y": 2077,
    "wires": []
  },
  {
    "id": "fb3ad86a.cf7a08",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "↑just for testing",
    "info": "\n ",
    "x": 121,
    "y": 2111,
    "wires": []
  },
  {
    "id": "65355b70.f421b4",
    "type": "join",
    "z": "25081f9e.f5f34",
    "name": "",
    "mode": "auto",
    "build": "string",
    "property": "payload",
    "propertyType": "msg",
    "key": "topic",
    "joiner": "\\n",
    "joinerType": "str",
    "accumulate": "false",
    "timeout": "",
    "count": "",
    "reduceRight": false,
    "x": 951,
    "y": 2039,
    "wires": [
      [
        "ba401a28.07edd8",
        "dd9aeada.78aa08"
      ]
    ]
  },
  {
    "id": "d7a0e21b.c7d47",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "↓modify",
    "info": "",
    "x": 796,
    "y": 2051,
    "wires": [],
    "icon": "font-awesome/fa-edit"
  },
  {
    "id": "847b1465.a7c858",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "↑modify",
    "info": "",
    "x": 290,
    "y": 1710,
    "wires": [],
    "icon": "font-awesome/fa-edit"
  },
  {
    "id": "40dc9f97.d2fdc",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "↑modify",
    "info": "",
    "x": 750,
    "y": 1750,
    "wires": [],
    "icon": "font-awesome/fa-edit"
  },
  {
    "id": "9fac1ab6.7839e8",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "↑modify",
    "info": "",
    "x": 713,
    "y": 1918,
    "wires": [],
    "icon": "font-awesome/fa-edit"
  },
  {
    "id": "be6b3b4e.443648",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "↑modify?",
    "info": "",
    "x": 305,
    "y": 2066,
    "wires": [],
    "icon": "font-awesome/fa-edit"
  },
  {
    "id": "c74a5f3d.b3a48",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "↑modify?",
    "info": "",
    "x": 321,
    "y": 1882,
    "wires": [],
    "icon": "font-awesome/fa-edit"
  },
  {
    "id": "ca002798.a37758",
    "type": "comment",
    "z": "25081f9e.f5f34",
    "name": "↓modify?",
    "info": "",
    "x": 945,
    "y": 1656,
    "wires": [],
    "icon": "font-awesome/fa-edit"
  },
  {
    "id": "b9f2373e.3c56d8",
    "type": "change",
    "z": "25081f9e.f5f34",
    "name": "smallest first",
    "rules": [
      {
        "t": "set",
        "p": "payload",
        "pt": "msg",
        "to": "$sort(payload, function($l, $r) {\t  $count($r.membersData) < $count($l.membersData)\t})\t\t",
        "tot": "jsonata"
      }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 464,
    "y": 2039,
    "wires": [
      [
        "a474fde9.320a7"
      ]
    ]
  },
  {
    "id": "88e9fa70.4a53e8",
    "type": "sonos-config",
    "name": "your_player_dns",
    "serialnum": "",
    "ipaddress": "sonoskitchen.fritz.box"
  }
]